/*import java.util.Scanner;

public class Num {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入一个数:");
        int num= scanner.nextInt();
        int i=0;
        int count=0;
        for(i=0;i<32;i++){
            if((num&(1<<i))==(1<<i)){
                count++;
            }
        }
        System.out.println("二进制1的个数:"+count);
    }
}*/

import java.util.Scanner;

public class Num {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入一个数:");
        int num= scanner.nextInt();
        int i=0;
        int count=0;

 while(num!=0){
         num&=num-1;
         count++;
         }
        System.out.println("二进制1的个数:"+count);
    }
}
